//
//  ViewController.m
//  06_NavigationController
//
//  Created by 徐昊 on 16/7/21.
//  Copyright © 2016年 徐昊. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor redColor];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    // 1.标题
    self.title = @"我是标题";
    self.navigationItem.title = @"sb";
    // 2.titleView 标题视图
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"韩旭", @"王鍠"]];
    segment.frame = CGRectMake(100, 100, 150, 44);
    // 标题视图, 修改x, y对本身位置没有影响
    self.navigationItem.titleView = segment;
    // 3.leftBarButtonItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:segment action:@selector(comeBack:)];
    // 4.rightBarButtonItem
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(takePhoto:)];
    // 5. leftBarButtonItems
    UIBarButtonItem *barButtonItemTitle = [[UIBarButtonItem alloc] initWithTitle:@"XXX" style:UIBarButtonItemStylePlain target:self action:@selector(clickItem:)];
    self.navigationItem.leftBarButtonItems = @[barButtonItemTitle];
    // 6. rightBarButtonItems
    // barButtonItems数组中1-2个Item为最优
    // 7.隐藏navigationBar YES 隐藏, NO, 不隐藏, 默认为NO
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.navigationBarHidden = NO;
    // 8.navigationBar背景样式 默认为 Default
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    // 9.navigationBar背景颜色
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    // 10.barTintColor Bar的颜色
    self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
    // 11.tintColor Bar上元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    // 12.tanslucent 管理半透明效果, YES为开启, NO为关闭
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor blueColor];
    button.frame = CGRectMake(0, 0, 200, 200);
    [self.view addSubview:button];
    // 设为YES时, self.view坐标系从原点开始
    // 设置为NO时, self.view坐标系从navigationBar下面开始
    self.navigationController.navigationBar.translucent = YES;
    // 13.改变坐标效果, 与translucent 为NO时效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    // 页面跳转相关
    // 1.push 入栈
    // 2.pop 出栈
    // 3.viewController存放navigationController里所有的控制器
    // 4.topViewController栈顶视图控制器
    // 5.visibleViewController 课件视图控制器
}
- (void)comeBack:(UIButton *)button {
    NSLog(@"返回");
}
- (void)takePhoto:(UIButton *)button {
    NSLog(@"照相");
}
- (void)clickItem:(UIButton *)button {
    // 将视图控制器入栈
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
